//
//  PickFoodItemTableViewCell.m
//  ZooNgonDoiOS
//
//  Created by Trung sound on 8/9/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "PickFoodItemTableViewCell.h"
#import "UIImage+Crop.h"

@implementation PickFoodItemTableViewCell
@synthesize btnView0 = _btnView0;
@synthesize vImgFood = _vImgFood;
@synthesize lbFoodName = _lbFoodName;
@synthesize lbFoodCost = _lbFoodCost;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        _btnView0 = [[UIButton alloc]initWithFrame:CGRectMake(11, 5, 290, 65)];
        [_btnView0 setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:IMG_PICKFOODROW_NORMAL]]];
        
        _vImgFood = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 53, 53)];
        [_vImgFood setImage:[UIImage imageNamed:@"pickfood_img.png"]];
        
        hjManagedImageV = [[HJManagedImageV alloc]initWithFrame:CGRectMake(5, 5, 53, 53)];

        NSURL *myURL = [[NSURL alloc]initWithString:@"http://i136.photobucket.com/albums/q197/bermuda2810/main_dish_image-1.jpg"];
        hjManagedImageV.url = myURL;
        hjManagedImageV.sizeOfimage = CGSizeMake(53, 53);
        [hjManagedImageV.image imageByScalingAndCroppingForSize:CGSizeMake(53, 53)];        
        obManager = [[HJObjManager alloc]initWithLoadingBufferSize:16 memCacheSize:20];
        [obManager manage:hjManagedImageV];
        
        
        _lbFoodName = [[UILabel alloc]initWithFrame:CGRectMake(65, 15, 150, 25)];
        [_lbFoodName setBackgroundColor:[UIColor clearColor]];
        [_lbFoodName setFont:[UIFont boldSystemFontOfSize:15]];
        
        _lbFoodCost = [[UILabel alloc]initWithFrame:CGRectMake(12, 12, 26, 18)];
        [_lbFoodCost setBackgroundColor:[UIColor clearColor]];
        [_lbFoodCost setTextAlignment:UITextAlignmentRight];

        [_lbFoodCost setFont:[UIFont boldSystemFontOfSize:15]];
        
        _lbUnit = [[UILabel alloc]initWithFrame:CGRectMake(42, 12, 11, 11)];
        [_lbUnit setBackgroundColor:[UIColor clearColor]];
        [_lbUnit setText:@"K"];
        [_lbUnit setFont:[UIFont systemFontOfSize:15]];
            
        _vImgCost = [[UIImageView alloc]initWithFrame:CGRectMake(236, 8, 59, 46)];
//        _imgBgCost = [[UIImage imageNamed:IMG_COST_BACKGROUND]resizableImageWithCapInsets:UIEdgeInsetsMake(15, 15, 15, 15)];
        _imgBgCost = [UIImage imageNamed:IMG_COST_BACKGROUND];
        [_vImgCost addSubview:_lbFoodCost];
        [_vImgCost addSubview:_lbUnit];
        
        [_vImgCost setImage:_imgBgCost];
        
        [_btnView0 addSubview:hjManagedImageV];
        [_btnView0 addSubview:_lbFoodName];
        [_btnView0 addSubview:_vImgCost];
        
        [self addSubview:_btnView0];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
